package com.example.action;

import javax.swing.table.DefaultTableModel;
import java.util.HashSet;
import java.util.Set;

// 自定义可编辑表格模型，用于控制表格中的列是否可编辑
public class EditableTableModel extends DefaultTableModel {
    private Set<String> editableColumns = new HashSet<>();

    public void setEditableColumns(Set<String> editableColumns) {
        this.editableColumns = editableColumns;
        fireTableStructureChanged(); // 刷新表结构
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        String columnName = getColumnName(column);
        return editableColumns.contains(columnName);
    }
}
